Latchup Immune Microcontroller System

ABSTRACT

A latchup immune microcontroller system with a power supply and a filter designed to eliminate external risks of triggering a latchup of a microcontroller caused by the power supply; a clock circuit with a clock frequency and a layout for eliminating external risks of triggering a latchup of the microcontroller caused by a high-frequency clock signal; a reset circuit that uses an optical triggering mechanism acting as a common power supply and an isolated power supply, the power detection circuit and a discharge circuit react in chain in time, avoid risks of triggering latchups of the microcontroller caused by reset signals; an interrupt with a high priority level and the discharge circuit react in chain in time to enhance data security, and output terminals are turned off in sequence to remove external causes of latchup. An application method of an I/O port to eliminate triggers of latchup of the microcontroller.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is the national stage entry of InternationalApplication No. PCT/CN2019/088139, filed on May 23, 2019, which is basedupon and claims priority to Chinese Patent Application No.201810513018.X, filed on May 25, 2018, the entire contents of which areincorporated herein by reference.

TECHNICAL FIELD

The present invention relates to the field of electronics technology,and in particular to a latchup immune microcontroller system.

BACKGROUND

A complementary metal oxide semiconductor (CMOS) process has advantagessuch as low power consumption, a proportionless logic design, and alarge noise margin, and becomes a preferred technology for a digitalcircuit, an analog circuit, and a hybrid circuit in which an analogcircuit and a digital circuit are formed on the same chip. However, aninherent parasitic bipolar transistor in a CMOS structure may beactivated when being triggered by some conditions to form a positivefeedback to generate a latchup. As a result, a fault occurs in anintegrated circuit (IC), leading to a change in data or a logic status,data loss or even a chip burnout in severe cases, causing a permanentcircuit failure.

Currently, an IC layout process design can basically avoid theprobability of a latchup in a chip. It is generally acknowledged atpresent in the industry that a latchup is mainly triggered by anexternal condition, that is, by the aspect of circuit application. Thegenerally acknowledged external trigger conditions that tend to cause anIC latchup mainly include factors such as an external signal or noiseinterference, especially, a signal inversion at an input/output (I/O)pin of a chip, a voltage at an I/O pin being greater than a supplyvoltage of a device or lower than a ground voltage, a voltage or currentat an I/O pin changing excessively fast, and a surge or drop at a powerpin of a device. Applications of modern CMOS circuits, especiallyvarious microprocessors represented by embedded control, growgeometrically. During prototype debugging and system application,various errors such as software running out, data loss, and parameterchange often occur. To resolve such problems, with errors in softwareitself being excluded, because of the variety and complexity of actualapplication circuits and external environments, problems may still existeven though many engineers have adopted many foregoing measures ofavoiding a latchup.

SUMMARY

External factors such as a signal inversion at an I/O pin of a chip, avoltage at an I/O pin being greater than a supply voltage of a device orlower than a ground voltage, a voltage or current at an I/O pin changingexcessively fast, and a surge or drop at a power pin of a device triggeran IC latchup, leading to errors during prototype debugging and systemapplication.

A latchup immune microcontroller system includes a microcontroller, aclock circuit, a power supply circuit, a reset circuit, and an inputsignal processing circuit, where the clock circuit includes a firstcapacitor, a crystal oscillator, and a second capacitor that aresequentially connected in series, two ends of the series circuit areconnected, a common terminal of the first capacitor and the crystaloscillator is connected to an XTAL1 pin of the microcontroller, a commonterminal of the crystal oscillator and the second capacitor is connectedto an XTAL2 pin of the microcontroller, and a common terminal of thefirst capacitor and the second capacitor is connected to a ground ofdirect-current stabilized power supply;

the power supply circuit includes a direct-current stabilized powersupply and a filter circuit, the filter circuit includes a thirdcapacitor, a filter inductor, and a fourth capacitor that aresequentially connected in series, two ends of the series circuit areconnected, a common terminal of the third capacitor and the filterinductor is connected as an input terminal of the filter circuit to thedirect-current stabilized power supply, a common terminal of the filterinductor and the fourth capacitor is connected as an output terminal ofthe filter circuit to a VCC pin of the microcontroller, and a commonterminal of the third capacitor and the fourth capacitor is connected toa GND pin of the microcontroller and is connected to the ground ofdirect-current stabilized power supply;

the reset circuit includes a first-order reset circuit, a powerdetection circuit, and a discharge circuit, the first-order resetcircuit includes a first reset element and a second reset element, oneend of the first reset element is connected to the direct-currentstabilized power supply, the other end of the first reset element isconnected to one end of the second reset element, the other end of thesecond reset element is connected to the ground of direct-currentstabilized power supply, the power detection circuit is connected to thedischarge circuit by an optocoupler, the power detection circuitincludes a fifth capacitor, a first diode, and a light-emitting diodethat is located inside the optocoupler, an anode of the first diode anda cathode of the light-emitting diode are separately connected to adetection power supply, a positive electrode of the fifth capacitor anda cathode of the first diode are separately connected to an anode of thelight-emitting diode, a negative electrode of the fifth capacitor isconnected to a detection power ground, the discharge circuit includes abipolar phototransistor inside the optocoupler and the second resetelement in the first-order reset circuit, an emitter of the bipolarphototransistor is connected to the ground of direct-current stabilizedpower supply, a collector of the bipolar phototransistor is connected toa common terminal of the first reset element and the second resetelement, the common terminal of the first reset element and the secondreset element is further connected to an RST pin of the microcontroller,the common terminal of the first reset element and the second resetelement is further connected to an input terminal of a CMOS buffer, andan output terminal of the CMOS buffer is connected to an externalinterrupt of the microcontroller, where the first reset element is areset resistor, and the second reset element is a reset capacitor, orthe first reset element is a reset capacitor, and the second resetelement is a reset resistor; and

the input signal processing circuit includes a first resistor, a secondresistor, a sixth capacitor, a third resistor, a fourth resistor, and acomparator, one end of the first resistor is connected to an inputsignal, the other end of the first resistor is separately connected toone end of the second resistor, one end of the sixth capacitor, and apositive input terminal of the comparator, the other end of the secondresistor is connected to the direct-current stabilized power supply, theother end of the sixth capacitor is connected to the ground ofdirect-current stabilized power supply, one end of the third resistor isconnected to the direct-current stabilized power supply, the other endof the third resistor is connected to one end of the fourth resistor,the other end of the fourth resistor is connected to the ground ofdirect-current stabilized power supply, a common terminal of the thirdresistor and the fourth resistor is connected to a negative inputterminal of the comparator and provides a reference voltage, and anoutput terminal of the comparator is connected to a signal inputterminal of the microcontroller.

In a further technical solution of the system, the direct-currentstabilized power supply is formed by processing utility power, theutility power is transformed to obtain a low-voltage power supply, thelow-voltage power supply is rectified to obtain a direct-current powersupply, and the direct-current power supply is stabilized to obtain thedirect-current stabilized power supply;

when the duration during which an output change of the direct-currentstabilized power supply lags behind an output change of the utilitypower does not reach preset duration, the detection power supply is thedirect-current stabilized power supply, and the detection power groundis the ground of direct-current stabilized power supply; and

when the duration during which the output change of the direct-currentstabilized power supply lags behind the output change of the utilitypower reaches the preset duration, the detection power supply is thedirect-current power supply, and the detection power ground is thedirect-current power ground.

In a further technical solution of the system, the utility power passesthrough a switched-mode power supply to obtain the direct-currentstabilized power supply; or

the utility power sequentially passes through a transformer and a linearpower supply to obtain the direct-current stabilized power supply, thetransformer includes a shielding layer, the shielding layer is grounded,the secondary of the transformer includes a plurality of power loopsformed by windings, and the power loops do not have a common ground.

In a further technical solution of the system, a clock frequency of theclock circuit is a frequency determined by adding a preset margin to ameasured frequency, and the measured frequency is a frequency calculatedaccording to a minimum time of completing real-time events by themicrocontroller system.

In a further technical solution of the system, when the microcontrollersystem uses printed circuit board (PCB) wiring, the crystal oscillatorin the clock circuit is close to the microcontroller, and a housing ofthe crystal oscillator is grounded, the outside of the clock circuit issurrounded by a grounding wire, and no other signal wire is arrangedbelow the clock circuit.

In a further technical solution of the system, when the microcontrolleris a low-level reset microcontroller, the first reset element in thefirst-order reset circuit is a reset resistor, and the second resetelement is a reset capacitor, where a positive electrode of the resetcapacitor is connected to one end of the reset resistor, a negativeelectrode of the reset capacitor is connected to the ground ofdirect-current stabilized power supply, the other end of the resetresistor is connected to the direct-current stabilized power supply, andthe first-order reset circuit forms a first-order integrated resetcircuit; and

when the microcontroller is a high-level reset microcontroller, thefirst reset element in the first-order reset circuit is a resetcapacitor, and the second reset element is a reset resistor, where apositive electrode of the reset capacitor is connected to thedirect-current stabilized power supply, a negative electrode of thereset capacitor is connected to one end of the reset resistor, the otherend of the reset resistor is connected to the ground of direct-currentstabilized power supply, and the first-order reset circuit forms afirst-order differential reset circuit.

In a further technical solution of the system, an optocoupler element isused to perform isolated transmission of an input signal and an outputsignal of the microcontroller, one transistor-transistor logic (TTL)port of the microcontroller drives at most eight TTL ports or 10 CMOSports, one CMOS port of the microcontroller drives at most two TTL portsand 20 CMOS ports, and an idle pin of the microcontroller is set tooutput or is connected to the direct-current stabilized power supply bya pull-up resistor or is connected to the ground of direct-currentstabilized power supply by a pull-down resistor.

The latchup immune microcontroller system disclosed in this applicationincludes a power supply circuit design, a clock circuit design, a resetcircuit design, and an I/O port design outside a microcontroller.Measures are adopted in various aspects such as a power supply of thesystem, a clock, resetting, and an I/O port to effectively avoid a riskof triggering a latchup of the microcontroller caused by an externalcondition. The selection of a power supply and a filter design method ofthe power supply are used to eliminate an external risk of triggering alatchup of the microcontroller caused by the aspect of a power supply.The selection of a clock frequency and a layout method of a clockcircuit are used to eliminate an external risk of triggering a latchupof the microcontroller caused by the aspect of a high-frequency clocksignal. A reset circuit designed by using an “optical trigger” mechanismhas application compatibility of a “common power supply” and an“isolated power supply”, so that a power detection circuit and adischarge circuit react in chain in time, thereby effectively avoiding arisk of triggering a latchup of the microcontroller caused by a resetsignal. An interrupt with a high priority level and the dischargecircuit react in chain in time to ensure data security, and outputterminals are turned off in sequence to effectively remove an externalformation condition of a latchup of the microcontroller. An effectiveapplication method of an I/O port is used to eliminate an external riskof triggering a latchup of the microcontroller caused by the aspect ofan I/O port.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic diagram of a general design solution of a latchupimmune microcontroller system according to this application;

FIG. 2 is a circuit diagram of a filter circuit in a power supplycircuit design;

FIG. 3 is a circuit diagram of a clock circuit in a clock circuitdesign;

FIG. 4 is a schematic diagram of position arrangement and wiring of apower supply circuit, a clock circuit, and a microcontroller;

FIG. 5 is a circuit diagram of a reset circuit of an existingmicrocontroller;

FIG. 6 is a working characteristic diagram of the reset circuit shown inFIG. 5;

FIG. 7 is a circuit diagram of another reset circuit of an existingmicrocontroller;

FIG. 8 is a circuit diagram of a reset circuit in a reset circuitdesign; and

FIG. 9 is a circuit diagram of an input signal processing circuit in anI/O port design.

DETAILED DESCRIPTION

Specific implementations of the present invention are further describedbelow with reference to the accompanying drawings.

This application discloses a latchup immune microcontroller system.Measures are adopted in various aspects such as a power supply design, aclock circuit design, a reset circuit design, and an I/O port design inthe system to effectively avoid a risk of triggering a latchup of amicrocontroller caused by an external condition. A general designsolution of the system is shown in FIG. 1. The four aspects areseparately described in this application.

1. Power Supply Circuit Design

With the development of semiconductor technology and the increase inportable application requirements, current microcontroller products havea wider operating voltage range (usually 1.8 V to 6 V) and lower powerconsumption (usually less than 30 mA). Some designers tend tomisapprehend that there is no strict requirement in terms of a powersupply for supplying power to a microcontroller. In fact, operatingcurrents provided in the data manual are merely average values. In anextreme case, for example, a case in which all I/O ports of themicrocontroller simultaneously undergo a status change, largefluctuations are generated in a power output, and an instantaneous peakcurrent may be up to hundreds of milliamperes. Therefore, a power supplycircuit is designed by using the following method in this application.

A power supply circuit part mainly includes a direct-current stabilizedpower supply VCC and a filter circuit. The direct-current stabilizedpower supply VCC is formed by processing utility power. The utilitypower is transformed to obtain a low-voltage power supply VB. Thelow-voltage power supply VB is rectified to obtain a direct-currentpower supply VZ. The direct-current power supply VZ is stabilized toobtain the direct-current stabilized power supply VCC. In the process offorming the direct-current stabilized power supply VCC:

(1) It is necessary to provide the direct-current power supply VZ withsufficient power and stable amplitude.

(2) If there is a mature switched-mode power supply design or anappropriate switched-mode power supply is commercially available, theutility power directly passes through the switched-mode power supply toobtain the direct-current stabilized power supply VCC.

(3) If there is no mature switched-mode power supply design and noappropriate switched-mode power supply is commercially available, aconventional “transformer+linear power supply” manner is used. Theutility power sequentially passes through a transformer and a linearpower supply to obtain the direct-current stabilized power supply VCC.In this manner, during the customization or purchasing of thetransformer, it is required that the transformer has a shielding layer,and a shielding terminal led out from the shielding layer is grounded. Aplurality of windings should be selected according to a power supplyrequirement of the system for the secondary of the transformer to formpower loops. The power loops do not have a common ground.

The obtained direct-current stabilized power supply VCC is connected tothe filter circuit shown in FIG. 2. The filter circuit includes a thirdcapacitor C3, a filter inductor L1, and a fourth capacitor C4 that aresequentially connected in series. Two ends of the series circuit areconnected. A common terminal of the third capacitor C3 and the filterinductor L1 is connected as an input terminal of the filter circuit tothe direct-current stabilized power supply VCC. A common terminal of thefilter inductor L1 and the fourth capacitor C4 is connected as an outputterminal of the filter circuit to a VCC pin (a main power supply pin) ofthe microcontroller as a power supply. In this application, fordistinguishing, +V represents the VCC pin of the microcontroller. Thefilter circuit can effectively absorb a peak pulse signal in thedirect-current stabilized power supply VCC, and eliminate an externalrisk of triggering a latchup of the microcontroller caused by the aspectof a power supply. A common terminal of the third capacitor C3 and thefourth capacitor C4 is connected to a GND pin of the microcontroller andis connected to a ground of the direct-current stabilized power supply.

2. Clock Circuit Design

Refer to FIG. 3 for the circuit diagram of a clock circuit used in thisapplication. The clock circuit includes a first capacitor C1, a crystaloscillator X1, and a second capacitor C2 that are sequentially connectedin series. Two ends of the series circuit are connected. A commonterminal of the first capacitor C1 and the crystal oscillator X1 isconnected to an XTAL1 pin of the microcontroller. A common terminal ofthe crystal oscillator X1 and the second capacitor C2 is connected to anXTAL2 pin of the microcontroller. A common terminal of the firstcapacitor C1 and the second capacitor C2 is connected to a ground ofdirect-current stabilized power supply.

Under the premise of satisfying a functional requirement of themicrocontroller system, the clock circuit should minimize a clockfrequency, to help to improve the latchup immunity of themicrocontroller. The method for determining a clock frequency in thisapplication is as follows:

(1) Real-time events that need to be processed, for example,interruption and timing, are listed first.

(2) The time required for completing these real-time events by themicrocontroller is measured to confirm a minimum time allowed by themicrocontroller system to complete these real-time events.

(3) A required clock frequency is measured according to the determinedtime. The clock frequency is a measured frequency.

(4) A preset margin is added to the measured frequency to obtain a clockfrequency of the microcontroller system. The preset margin may becustomized. For example, it is set to add 20% to 30% to the measuredfrequency to obtain the clock frequency.

For high-frequency characteristics of the clock circuit, during PCBwiring in the microcontroller system, the following method should beused:

(1) The crystal oscillator should be as close to the microcontroller aspossible. A lead wire needs to be short.

(2) It is optimal to surround the clock circuit with grounding wires.

(3) A housing of the crystal oscillator is grounded.

(4) No other signal wire is arranged below the clock circuit.

For example, the most cost-effective commercially available dual in-linepackage (DIP) is packaged with an MCS-51 series microcontroller. Referto FIG. 4 for a schematic diagram of position arrangement and wiringused in PCB layout and wiring of the power supply circuit and the clockcircuit of the microcontroller.

3. Reset Circuit Design

A reset circuit of a current common conventional microcontroller isshown in FIG. 5. A reset resistor R₀ is connected in series to a resetcapacitor CR. One end of the series circuit is connected to thedirect-current stabilized power supply VCC, and the other end of theseries circuit is connected to the ground of direct-current stabilizedpower supply. A common terminal of the reset resistor R₀ and the resetcapacitor CR is connected to an RST pin of the microcontroller. Anoperating waveform of the reset circuit shown in FIG. 5 is shown in FIG.6. When the system is powered up, the direct-current stabilized powersupply VCC mainly charges the reset capacitor CR through the resetresistor R₀ to generate a reset signal. In this case, themicrocontroller is still not in an operating state. When the powersupply is down, electricity discharged from the reset capacitor CRdirectly impacts the RST pin of the microcontroller. As can be seen fromFIG. 6, when the power supply is turned on or off, a voltage change atthe RST pin of the microcontroller satisfies the feature of an externaltrigger condition to cause a latchup of the microcontroller. For thisproblem, in one existing improvement method, a diode Do is connected inparallel at two ends of the reset resistor R₀. As shown in FIG. 7,compared with the reset circuit shown in FIG. 5, a diode dischargecircuit is added to the reset circuit shown in FIG. 7. However, limitedby a drop characteristic of the power supply, the discharge for the RSTpin of the microcontroller still cannot be avoided. When the system iscontinuously rapidly powered on and off, such impact becomes frequent,making a major trigger factor for a latchup of the microcontroller.

To resolve this problem, a new reset circuit is designed in thisapplication. The reset circuit in this application includes three parts:a first-order reset circuit, a power detection circuit, and a dischargecircuit. The power detection circuit is connected to the dischargecircuit by an optocoupler U2. The circuit parts are connected by signalwires. A specific description is provided as follows:

(1) First-Order Reset Circuit

It should be noted that the first-order reset circuit may be consideredas the reset circuit shown in FIG. 5. Therefore, the symbols same asthose in FIG. 5 are used for the reset resistor R₀ and the resetcapacitor CR in the first-order reset circuit. The first-order resetcircuit includes a first reset element and a second reset element. Oneend of the first reset element is connected to the direct-currentstabilized power supply VCC. The other end of the first reset element isconnected to one end of the second reset element. The other end of thesecond reset element is connected to the ground of direct-currentstabilized power supply. The first reset element is the reset resistorR₀, and the second reset element is the reset capacitor CR.Alternatively, the first reset element is the reset capacitor CR, andthe second reset element is the reset resistor R₀.

Specifically, when the microcontroller is a low-level resetmicrocontroller, the first reset element is a reset resistor R₀, and thesecond reset element is a reset capacitor CR. A positive electrode ofthe reset capacitor CR is connected to one end of the reset resistor R₀.A negative electrode of the reset capacitor CR is connected to theground of direct-current stabilized power supply. The other end of thereset resistor R₀ is connected to the direct-current stabilized powersupply VCC. The first-order reset circuit forms a first-order integratedreset circuit. This application is described by using this case as anexample. For a circuit diagram of the reset circuit, refer to FIG. 8.

When the microcontroller is a high-level reset microcontroller, thefirst reset element in the first-order reset circuit is a resetcapacitor CR, and the second reset element is a reset resistor R₀. Apositive electrode of the reset capacitor CR is connected to thedirect-current stabilized power supply. A negative electrode of thereset capacitor CR is connected to one end of the reset resistor R₀. Theother end of the reset resistor R₀ is connected to the ground ofdirect-current stabilized power supply. The first-order reset circuitforms a first-order differential reset circuit. Based on the circuitdiagram shown in FIG. 8, a person skilled in the art may explicitlyobtain the circuit diagram of the reset circuit in this case. Detailsare not described again in this application.

(2) Power Detection Circuit

The power detection circuit includes a fifth capacitor C5, a first diodeD1, and a light-emitting diode that is located inside the optocouplerU2. An anode of the first diode D1 and a cathode of the light-emittingdiode are separately connected to a detection power supply V₀. Apositive electrode of the fifth capacitor C5 and a cathode of the firstdiode D1 are separately connected to an anode of the light-emittingdiode. A negative electrode of the fifth capacitor C5 is connected to adetection power ground.

(3) Discharge Circuit

The discharge circuit includes a bipolar phototransistor inside theoptocoupler U2 and the second reset element in the first-order resetcircuit. An emitter of the bipolar phototransistor is connected to theground of direct-current stabilized power supply. A collector of thebipolar phototransistor is connected to a common terminal of the firstreset element and the second reset element. The common terminal of thefirst reset element and the second reset element is further connected tothe RST pin of the microcontroller. The common terminal of the firstreset element and the second reset element is further connected to aninput terminal of a CMOS buffer U3. An output terminal of the CMOSbuffer U3 is connected to an external interrupt of the microcontroller.The external interrupt is usually set with the highest priority level,to form the reset circuit, reacting in chain with the interrupt, of alatchup immune microcontroller.

In the reset circuit of this application, the reset resistor R₀, thereset capacitor CR, and the collector of the bipolar phototransistorinside the optocoupler U2 are connected together, and are directlyconnected to the RST pin of the microcontroller without any intermediatebuffer. An “optical trigger” mechanism is used to enable the powerdetection circuit and the discharge circuit to react in chain. When thepower supply is down, electrical charges at an end of the RST pin isdirectly released through the discharge circuit, so as to minimize theimpact on the RST pin of the microcontroller, making it more likely fora CMOS microcontroller to enter a latchup state. For example, amicrocontroller interrupt (assumed to be TO) connected to the CMOSbuffer U3 is set to be triggered by a falling edge, and the prioritylevel is set to the highest. An operating process of the entire resetcircuit when the system is powered on and off is as follows:

When the direct-current stabilized power supply VCC is powered up,because of a transient effect during the charging of the reset capacitorCR, an initial potential of the voltage at the positive electrode of thereset capacitor CR is equal to the ground of direct-current stabilizedpower supply. After a particular delay time, the charging of the resetcapacitor CR is completed. In this process, the voltage at the positiveelectrode of the reset capacitor CR gradually becomes a high level. Theprocess is used to provide a reset signal to the microcontroller. Inthis process, the microcontroller is in a reset process and is not in anoperating state yet. The output terminal of the CMOS buffer U3 is at alow level, and the interrupt I0 does not work. In this process, thelength of the delay time depends on the values of the reset resistor R₀and the reset capacitor CR. Specific values of the reset resistor R₀ andthe reset capacitor CR may be used to determine the delay time accordingto a functional requirement of a designed object. R₀*CR is referred toas a time constant.

During power-on and normal operation, the first diode D1 in the powerdetection circuit is in forward conduction. The light-emitting diodeinside the optocoupler U2 is in reverse conduction and is not turned on.Therefore, the bipolar phototransistor inside the optocoupler U2 is alsonot in conduction, and the discharge circuit is in an off state, theoperation of the first-order reset circuit is not affected, and themicrocontroller operates normally. In this case, the output terminal ofthe CMOS buffer U3 is at a high level. In this process, the interrupt I0also does not work. Meanwhile, the detection power supply V₀ in thepower detection circuit charges the fifth capacitor C5 through the firstdiode D1 to store energy. After the charging is completed, the voltageat the positive electrode of the fifth capacitor C5 is equal to that ofthe detection power supply V₀.

When the detection power supply V₀ is down, the voltage of the detectionpower supply V₀ decreases. In this case, the voltage at the positiveelectrode of the fifth capacitor C5 in the power detection circuit ishigher than that of the detection power supply V₀. The first diode D1 isreversely powered on and is not in conduction. The light-emitting diodeinside the optocoupler U2 is in forward conduction. The electricalenergy stored in the fifth capacitor C5 is released to the detectionpower supply V₀ through the light-emitting diode to form a current, soas to trigger the bipolar phototransistor inside the optocoupler U2 tobe in conduction. The discharge circuit is closed. The electrical energystored in the reset capacitor CR in the first-order reset circuit formsapproximately direct discharge to the ground through the bipolarphototransistor, so as to avoid the impact of the discharge of the resetcapacitor CR on the RST pin of the microcontroller. Meanwhile, with theconduction of the discharge circuit, the CMOS buffer U3 changes from ahigh level to a low level. That is, a falling edge is generated. In thiscase, the microcontroller immediately enters a process of the interruptI0 processing. In this process, the program first immediately stores alloperation data, and then sequentially turns off all output terminals.That is, before the direct-current stabilized power supply VCC actuallyfalls, the interrupt I0 and the discharge circuit react in chain intime, to sequentially complete the storage of data and the switching offof the output terminals, so that data loss caused by a sudden power cutand reset and impact on a CMOS circuit caused by sudden switching off ofall the output terminals are avoided, thereby effectively preventing theformation of an external condition of a latchup of the microcontrollerto a particular extent.

For the detection power supply V₀, the meaning is as follows: Asdescribed above, the utility power is sequentially transformed,rectified, and stabilized to obtain the direct-current stabilized powersupply VCC. The stabilization stage usually includes a three-terminalvoltage stabilizer or another form of switched-mode voltagestabilization technology, and generally includes a large number ofcapacitors. Therefore, when the utility power is down, thedirect-current stabilized power supply VCC usually starts to fall aftera millisecond-level or second-level lag behind the utility power.

When the duration during which an output change of the direct-currentstabilized power supply VCC lags behind an output change of the utilitypower does not reach preset duration, that is, usually, when the lag isless than a millisecond, it indicates that the power supply hasrelatively small inertia. A “common power supply” method may be used forthe reset circuit. That is, the power detection circuit and themicrocontroller share the direct-current stabilized power supply VCC.That is, the detection power supply V₀ is the direct-current stabilizedpower supply VCC, and the detection power ground is the ground ofdirect-current stabilized power supply.

When the duration during which the output change of the direct-currentstabilized power supply VCC lags behind the output change of the utilitypower reaches the preset duration, that is, usually, when the lag ismilliseconds or even seconds long, it indicates that the power supplyhas relatively large inertia. The “common power supply” method cannotactually immediately detect an actual power down symptom of the utilitypower. In this case, an “isolated preset supply” method may be used.That is, the rectified direct-current power supply VZ is used for thepower detection circuit, so that an actual power down of the utilitypower is detected in advance. The direct-current power supply VZ in arectified output stage already outputs direct current. Although thedirect current is not stable, with appropriate selection of the fifthcapacitor C5, the insensitivity to power supply fluctuations in thisstage may be implemented. If the utility power undergoes commonfluctuations, the discharge of the reset capacitor CR is not triggered.The light-emitting diode inside the optocoupler U2 triggers theconduction of the bipolar phototransistor only when the utility power isactually down and the voltage amplitude decreases to a particulardegree, to enable the reset capacitor CR to rapidly discharge, therebygreatly reducing the change time during which the reset signal lagsbehind the direct-current stabilized power supply VCC, thereby avoidingthe risk that the CMOS circuit enters a latchup caused by unstablesignals when the direct-current stabilized power supply VCC falls. Toput it simply, the “isolated power supply” detection method canimplement beforehand processing. That is, the actual power down of theutility power is detected in advance, and the discharge circuit isturned on in advance, so that the level at an end of the RST pin of themicrocontroller changes synchronously with the direct-current stabilizedpower supply VCC or even changes sooner than the direct-currentstabilized power supply VCC, so as to rapidly release charges and entera reset state, thereby effectively avoiding the risk that a CMOSmicrocontroller circuit enters a latchup.

The reset circuit in this application has the compatibility of a “commonpower supply technology” and an “isolated power supply technology”, sothat choices may be made according to an actual case to achieve bettereffectiveness and adaptability.

4. I/O Port Design

For an external trigger condition that tends to cause a latchup of themicrocontroller, the following measures are adopted to reduce anexternal latchup risk triggered by an I/O port.

(1) An optocoupler element is used to perform isolated transmission ofan input signal and an output signal. This is a relatively commonapproach at present. Details are not described in this application.

(2) The drive capability of an I/O port is fully considered. Generally,one TTL port drives eight TTL ports or 10 CMOS ports, and one CMOS portdrives two TTL ports and 20 CMOS ports. If the load is excessivelyheavy, the microcontroller may operate unstably.

(3) An idle pin of the microcontroller is set to output, or is connectedto the direct-current stabilized power supply VCC by a pull-up resistor,or is connected to the ground of direct-current stabilized power supplyby a pull-down resistor. The resistance values of the pull-up resistorand the pull-down resistor may be selected according to an actual case,and may be, for example, 1 kΩ.

(4) An input signal processing circuit is used to process an inputsignal. The input signal is compared with a reference voltage to improvethe “quality” of the input signal. This is equivalent to raising an“admission threshold” for the input signal. Useless external noisesignals are intercepted, thereby improving the latchup immune capabilityof the microcontroller against an external input signal.

For (4) in the foregoing, refer to FIG. 9 for the circuit diagram of theinput signal processing circuit. The input signal processing circuitincludes a first resistor R1, a second resistor R2, a sixth capacitorC6, a third resistor R3, a fourth resistor R4, and a comparator U4. Oneend of the first resistor R1 is connected to the input signal. The otherend of the first resistor R1 is separately connected to one end of thesecond resistor R2, one end of the sixth capacitor C6, and a positiveinput terminal of the comparator U4. The other end of the secondresistor R2 is connected to the direct-current stabilized power supplyVCC. The other end of the sixth capacitor C6 is connected to the groundof direct-current stabilized power supply. One end of the third resistorR3 is connected to the direct-current stabilized power supply VCC. Theother end of the third resistor R3 is connected to one end of the fourthresistor R4. The other end of the fourth resistor R4 is connected to theground of direct-current stabilized power supply. A common terminal ofthe third resistor R3 and the fourth resistor R4 is connected to anegative input terminal of the comparator U4 and provides the referencevoltage. An output terminal of the comparator U4 is connected to asignal input terminal of the microcontroller.

The foregoing provides only preferred implementations of thisapplication. The present invention is not limited to the foregoingembodiments. It may be understood that other improvements and changesthat are directly derived or conceived by a person skilled in the artwithout departing from the spirit and concept of the present inventionshall all fall within the protection scope of the present invention.

What is claimed is:
 1. A latchup immune microcontroller system,comprising a microcontroller, a clock circuit, a power supply circuit, areset circuit, and an input signal processing circuit, wherein the clockcircuit comprises a first capacitor, a crystal oscillator, and a secondcapacitor that are sequentially connected in series to form a seriescircuit, wherein two ends of the series circuit are connected, a commonterminal of the first capacitor and the crystal oscillator is connectedto an XTAL1 pin of the microcontroller, a common terminal of the crystaloscillator and the second capacitor is connected to an XTAL2 pin of themicrocontroller, and a common terminal of the first capacitor and thesecond capacitor is connected to a direct-current stabilized powersupply at a common ground; the power supply circuit comprises thedirect-current stabilized power supply and a filter circuit, wherein thefilter circuit comprises a third capacitor, a filter inductor, and afourth capacitor that are sequentially connected in series to form theseries circuit, wherein two ends of the series circuit are connected, acommon terminal of the third capacitor and the filter inductor isconnected as an input terminal of the filter circuit to thedirect-current stabilized power supply, a common terminal of the filterinductor and the fourth capacitor is connected as an output terminal ofthe filter circuit to a VCC pin of the microcontroller, and a commonterminal of the third capacitor and the fourth capacitor is connected toa GND pin of the microcontroller and is connected to the direct-currentstabilized power supply at the common ground; the reset circuitcomprises a first-order reset circuit, a power detection circuit, and adischarge circuit, the first-order reset circuit comprises a first resetelement and a second reset element, wherein a first end of the firstreset element is connected to the direct-current stabilized powersupply, a second end of the first reset element is connected to a firstend of the second reset element, a second end of the second resetelement is connected to the direct-current stabilized power supply atthe common ground, the power detection circuit is connected to thedischarge circuit by an optocoupler, the power detection circuitcomprises a fifth capacitor, a first diode, and a light-emitting diodethat is located inside the optocoupler, an anode of the first diode anda cathode of the light-emitting diode are separately connected to adetection power supply, a positive electrode of the fifth capacitor anda cathode of the first diode are separately connected to an anode of thelight-emitting diode, a negative electrode of the fifth capacitor isconnected to a detection power ground, the discharge circuit comprises abipolar phototransistor inside the optocoupler and the second resetelement in the first-order reset circuit, an emitter of the bipolarphototransistor is connected to the direct-current stabilized powersupply at the common ground, a collector of the bipolar phototransistoris connected to a common terminal of the first reset element and thesecond reset element, the common terminal of the first reset element andthe second reset element is further connected to an RST pin of themicrocontroller, the common terminal of the first reset element and thesecond reset element is further connected to an input terminal of a CMOSbuffer, and an output terminal of the CMOS buffer is connected to anexternal interrupt of the microcontroller, wherein the first resetelement is a reset resistor, and the second reset element is a resetcapacitor, or the first reset element is a reset capacitor, and thesecond reset element is a reset resistor; and the input signalprocessing circuit comprises a first resistor, a second resistor, asixth capacitor, a third resistor, a fourth resistor, and a comparator,a first end of the first resistor is connected to an input signal, theother a second end of the first resistor is separately connected to afirst end of the second resistor, a first end of the sixth capacitor,and a positive input terminal of the comparator, a second end of thesecond resistor is connected to the direct-current stabilized powersupply, a second end of the sixth capacitor is connected to thedirect-current stabilized power supply at the common ground, a first endof the third resistor is connected to the direct-current stabilizedpower supply, a second end of the third resistor is connected to a firstend of the fourth resistor, a second end of the fourth resistor isconnected to the ground of the direct-current stabilized power supply, acommon terminal of the third resistor and the fourth resistor isconnected to a negative input terminal of the comparator and provides areference voltage, and an output terminal of the comparator is connectedto a signal input terminal of the microcontroller.
 2. The systemaccording to claim 1, wherein the direct-current stabilized power supplyis formed by processing utility power, the utility power is transformedto obtain a low-voltage power supply, the low-voltage power supply isrectified to obtain a direct-current power supply, and thedirect-current power supply is stabilized to obtain the direct-currentstabilized power supply; when the duration during which an output changeof the direct-current stabilized power supply lags behind an outputchange of the utility power does not reach preset duration, thedetection power supply is the direct-current stabilized power supply,and the detection power ground is the ground of the direct-currentstabilized power supply; and when the duration during which the outputchange of the direct-current stabilized power supply lags behind theoutput change of the utility power reaches the preset duration, thedetection power supply is the direct-current power supply, and thedetection power ground is the direct-current power ground.
 3. The systemaccording to claim 2, wherein the utility power passes through aswitched-mode power supply to obtain the direct-current stabilized powersupply; or the utility power sequentially passes through a transformerand a linear power supply to obtain the direct-current stabilized powersupply, the transformer comprises a shielding layer, the shielding layeris grounded, a secondary winding of the transformer comprises aplurality of power loops formed by windings, and the power loops do nothave a common ground.
 4. The system according to claim 1, wherein aclock frequency of the clock circuit is a frequency determined by addinga preset margin to a measured frequency, and the measured frequency is afrequency calculated according to a minimum time of completing real-timeevents by the microcontroller system.
 5. The system according to claim1, wherein when the microcontroller system uses printed circuit board(PCB) wiring, the crystal oscillator in the clock circuit is adjacent tothe microcontroller, and a housing of the crystal oscillator isgrounded, exterior of the clock circuit is surrounded by a groundingwire, and no other signal wire is arranged below the clock circuit. 6.The system according to claim 1, wherein when the microcontroller is alow-level reset microcontroller, the first reset element in thefirst-order reset circuit is a reset resistor, and the second resetelement is a reset capacitor, wherein a positive electrode of the resetcapacitor is connected to one end of the reset resistor, a negativeelectrode of the reset capacitor is connected to the ground ofdirect-current stabilized power supply, the other end of the resetresistor is connected to the direct-current stabilized power supply, andthe first-order reset circuit forms a first-order integrated resetcircuit; and when the microcontroller is a high-level resetmicrocontroller, the first reset element in the first-order resetcircuit is a reset capacitor, and the second reset element is a resetresistor, wherein a positive electrode of the reset capacitor isconnected to the direct-current stabilized power supply, a negativeelectrode of the reset capacitor is connected to one end of the resetresistor, the other end of the reset resistor is connected to the groundof direct-current stabilized power supply, and the first-order resetcircuit forms a first-order differential reset circuit.
 7. The systemaccording to claim 1, wherein an optocoupler element is used to performisolated transmission of an input signal and an output signal of themicrocontroller, one transistor-transistor logic (TTL) port of themicrocontroller drives at most eight TTL ports or 10 CMOS ports, oneCMOS port of the microcontroller drives at most two TTL ports and 20CMOS ports, and an idle pin of the microcontroller is set to output, oris connected to the direct-current stabilized power supply by a pull-upresistor, or is connected to the ground of direct-current stabilizedpower supply by a pull-down resistor.